#pragma once
#include <string>
#include <functional>
#include <iostream>

class Task
{
    using func_t = std::function<void(int, const std::string &, const uint16_t &)>;
public:
    Task() = default;
    Task(func_t func, int newsockfd, const std::string &ip, const uint16_t &port)
        : _func(func), _newsockfd(newsockfd), _ip(ip), _port(port)
    {
    }
    ~Task() {}

    void operator()()
    {
        _func(_newsockfd, _ip, _port);
    }

private:
    int _newsockfd;
    std::string _ip;
    uint16_t _port;
    func_t _func;
};